<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body background="../style/shop/images/bg.jpg">
<h1>欢迎来到购物城！</h1>

<?php
session_start();
include("../conn/conn.php");
date_default_timezone_set("PRC");

//1.找出购物车中多少种商品和总价
$name = $_SESSION["name"];
$attr = array();
//如果购物车有商品，取出值
if(!empty($_SESSION["gwc"]))
{
    $attr = $_SESSION["gwc"];
}

$gs = count($attr);//$gs 商品数量
$sum = 0;//$sum 总价格,默认总价格为0
foreach($attr as $v)
{
    $v[0];
    $v[1]; 
    $sql = "select price from tb_video where ids ='{$v[0]}'";//查询单价
    
    $ajg = $db->Query($sql);
    $dj = $ajg[0][0];//单价
    
    $sum += $dj * $v[1];//总价=单价*数量
}
echo"<div>购物车中有:{$gs}种商品，商品总价为:{$sum}元</div>";
?>



<table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
    <tr>
        <td width="19%" align="center">编号</td>
        <td width="19%" align="center">名称</td>
        <td width="19%" align="center">价格</td>
        <td width="19%" align="center">产地</td>
        <td align="center">库存&nbsp;&nbsp;</td>
    </tr>
    <?php
    
     include("../conn/conn.php");
    
    $sql = "select * from tb_video";
    $arr = $db->Query($sql);
    
    foreach($arr as $v)
    {
        echo"<tr>
        <td>$v[0]</td>
        <td>$v[1]</td>
        <td>$v[2]</td>
        <td>$v[3]</td>
        <td>$v[4]</td>
        <td>$v[5]</td>
        <td><a href='gouwu_add.php?ids={$v[0]}'>购买</a></td>
        </tr>
        
        
        ";
        
    }
    
    
    
      
    ?>


</table>
<a href="chak_gouwu.php?ids={$v[0]}">查看购物车</a>


</body>
</html>